package com.javafactroy.kunlong.bip;

import com.javafactroy.kunlong.bip.icp.context.connpool.dxpftp.DxpFtpTemplatePool;
import com.javafactroy.kunlong.bip.icp.ftpclient.dxp.DxpFtpTemplate;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import com.javafactroy.kunlong.bip.icp.context.connpool.ftpclient.FTPClientPool;

import java.util.List;

@SpringBootTest(classes = {IcpAppl.class}, webEnvironment = SpringBootTest.WebEnvironment.NONE)
@ExtendWith(SpringExtension.class)
@Slf4j
public class TestDxpFtpClient {
    //Logger log = (Logger) LoggerFactory.getILoggerFactory().getLogger("ROOT");

    @Autowired
    FTPClientPool ftpClientPool;

    @Autowired
    DxpFtpTemplatePool dxpFtpTemplatePool;


    @Test
    public void test001_ftpClientPool() throws Exception {
        log.info("{}", dxpFtpTemplatePool.getPoolConfig());
        DxpFtpTemplate ftpClient = dxpFtpTemplatePool.borrowObject();
        try {
            boolean ismk = ftpClient.mkdir("/test/aaa");
            List<String> ls = ftpClient.ls("/test");
            log.info("ls ={}  {}", ismk, ls);
        } finally {
            dxpFtpTemplatePool.returnObject(ftpClient);
        }
    }

}

